import { Component, OnInit, EventEmitter, Input, Output } from '@angular/core';

@Component({
  selector: 'el-upload-dragger',
  templateUrl: './upload-dragger.component.html'
})
export class UploadDraggerComponent implements OnInit {
  @Input() disabled: boolean = false;
  @Output() change: EventEmitter<any> = new EventEmitter();
  @Input() dragger: boolean = false;

  constructor() { }

  ngOnInit(): void {
  }


  dragoverHandle(event: Event): void {
    event.preventDefault();
    if (this.disabled)
      return;
    this.dragger = true;
  };
  dragLeaveHandle(event: Event): void {
    event.preventDefault();
    this.dragger = false;
  };
  dropHandle(event: DragEvent): void {
    event.preventDefault();
    if (this.disabled)
      return;
    this.change.emit({ target: { files: event.dataTransfer ? event.dataTransfer.files : {} } });
  };
}
